<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>123</div>
    <a href="http://www.baidu.com">百度</a>
    <form action="http://www.baidu.com">
        <input type="submit" value="提交" name="sub">
    </form>
</body>
<script>
    let div = document.querySelector('div');
    let a = document.querySelector('a');
    div.addEventListener('click', fn);
    div.addEventListener('mouseover', fn);
    div.addEventListener('mouseout', fn);
    function fn(e) {
        console.log(e.type);
    }
    //阻止默认行为，比如让链接不跳转
    a.addEventListener('click', function(e){
        e.preventDefault();
    });
    //return false也可以做到以上效果，没有兼容性问题
    a.onclick = function(e){
        return false;
    }
</script>
</html>